<?php
class semailAction extends Action{
	function sends(){
		AdminAction::check();
		$this->display('admin@email');
	}

	function sending(){
		die();
		$email = addslashes($_GET['email']);
		error_reporting(E_ALL);
		//error_reporting(E_STRICT);
		date_default_timezone_set('Asia/Shanghai');
		include("semail/class.phpmailer.php");
		$myee = '568142527@qq.com';
		//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
		$mail             = new PHPMailer();
		$body             = file_get_contents('semail/email.html');
		$body             = eregi_replace("[\]",'',$body);
		$mail->IsSMTP();
		$mail->SMTPAuth   = true;                  // enable SMTP authentication
		$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
		$mail->Host       = "smtp.qq.com";      // sets GMAIL as the SMTP server
		$mail->Port       = 465;                   // set the SMTP port for the GMAIL server
		$mail->Username   = "568142527@qq.com";  // GMAIL username
		$mail->Password   = "wyflyaway";            // GMAIL password
		$mail->AddReplyTo("568142527@qq.com");
		$mail->From       = "568142527@qq.com";
		$mail->FromName   = "阿晖";
		$mail->Subject    = "我们刚刚做出了一个非常艰难的决定!";
		$mail->AltBody    = "此Email需要在支持HTML模式下查看!"; // optional, comment out and test
		$mail->WordWrap   = 50; //自动换行
		$mail->MsgHTML($body);
		$mail->AddAddress($email);
		//$mail->AddAttachment("images/phpmailer.gif");     // 附件
		$mail->IsHTML(true); //以HTML格式发送
		if($mail->Send()){
		$id = intval($_GET['id']);
		$user = D('email');
		$user->where('id='.$id)->setField('states',0);
		echo '<script>alert("OK")</script>';
		}else{
		echo '<script>alert("Error")</script>';
		}
		
		
		/*
		//error_reporting(E_ALL);
		error_reporting(E_STRICT);
		date_default_timezone_set('Asia/Shanghai');
		require_once('semail/class.phpmailer.php');
		$mail             = new PHPMailer();
		$body             = file_get_contents('semail/email.html');
		$body             = str_replace("[\]",'',$body);
		$mail->IsSMTP(); // telling the class to use SMTP
		$mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
		// 1 = errors and messages
		// 2 = messages only
		$mail->SMTPAuth   = true;                  // enable SMTP authentication
		$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
		$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
		$mail->Port       = 465;                   // set the SMTP port for the GMAIL server
		$mail->Username   = "peixunphp@gmail.com";  // GMAIL username
		$mail->Password   = "wyflyaway";            // GMAIL password
		$mail->SetFrom('1135287226@qq.com','京城培训');//设置发送人邮箱名,发送人名字
		$mail->AddReplyTo('1135287226@qq.com');//设置回复邮箱名,发送人名字
		$mail->Subject    = "我们刚刚做出了一个非常艰难的决定!";
		$mail->AltBody    = "此Email需要在支持HTML模式下查看!";
		$mail->MsgHTML($body);
		$address = addslashes($_GET['email']);
		//$address = "568142527@qq.com";//这里设置接收方的邮箱名
		$mail->AddAddress($address);//接收方的名字

		if($mail->Send()){
			$id = intval($_GET['id']);
			$user = D('email');
			$user->where('id='.$id)->setField('states',0);
			echo '<script>alert("OK")</script>';
		} else {
			echo '<script>alert("Error")</script>';
		}
		*/

	}

	function elists(){
		$user = D('email');
		$list = $user->where('states=1 and whos="568142527@qq.com"')->findAll();

		$this->assign('list',$list);
		$this->display('admin@elists');
	}


}
?>